package dbz.domain.dtos;

import java.util.ArrayList;
import java.util.List;

import dbz.domain.Card;
import dbz.domain.Fighter;
import dbz.domain.Ki;
import dbz.domain.attack.Attack;

public class CardDTO {

	String cardType;
	String id;
	String name;
	String hp;
	AttackDTO[] attacks;
	private String status;
	
	public CardDTO(Card card) {
		//id = card.getId().toString();
		if(card instanceof Fighter) {
			Fighter fighter = (Fighter)card;
			name = fighter.getName();
			hp = fighter.getHealth().getMaxHitPoints().toString();
			attacks = getAttacksDTO(fighter);
			cardType = "Luchador";
			status = fighter.getStatus().toString();
			
		} else if(card instanceof Ki) {
			cardType = "Ki";
		}
	}

	private AttackDTO[] getAttacksDTO(Fighter fighter) {
		List<AttackDTO> attacks = new ArrayList<AttackDTO>();
		for(Attack attack : fighter.getAttacks().values()) {
			attacks.add(new AttackDTO(attack));
		}
		return attacks.toArray(new AttackDTO[0]);
	}

	public String getCardType() {
		return cardType;
	}

	public void setCardType(String cardType) {
		this.cardType = cardType;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHp() {
		return hp;
	}

	public void setHp(String hp) {
		this.hp = hp;
	}

	public AttackDTO[] getAttacks() {
		return attacks;
	}

	public void setAttacks(AttackDTO[] attacks) {
		this.attacks = attacks;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
}
